#include <iostream>
#include <string>
using namespace std;

const int kMaxN = 110;
const int kMaxM = 110;

string g[kMaxN];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> g[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (g[i][j] == '*') {
        continue;
      }
      char cnt = '0';
      for (int x = max(i - 1, 0); x <= i + 1 && x < n; x++) {
        for (int y = max(j - 1, 0); y <= j + 1 && y < m; y++) {
          cnt += g[x][y] == '*';
        }
      }
      g[i][j] = cnt;
    }
  }
  for (int i = 0; i < n; i++) {
    cout << g[i] << "\n";
  }
  return 0;
}